home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Pinceles y lápices / BouncingGradientBrushBall / BouncingGradientBrushBall.cs next >
Encoding:
Text File  |  2002-05-14  |  944 b   |  33 lines

  1. //--------------------------------------------------------
  2. // BouncingGradientBrushBall.cs ⌐ 2001 by Charles Petzold
  3. //--------------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class BouncingGradientBrushBall: Bounce
  10. {
  11.     public new static void Main()
  12.     {
  13.         Application.Run(new BouncingGradientBrushBall());
  14.     }
  15.     public BouncingGradientBrushBall()
  16.     {
  17.         Text = "Bola con pincel degradado";
  18.     }
  19.     protected override void DrawBall(Graphics grfx, Rectangle rect)
  20.     {
  21.         GraphicsPath path = new GraphicsPath();
  22.         path.AddEllipse(rect);
  23.  
  24.         PathGradientBrush pgbrush = new PathGradientBrush(path);
  25.         pgbrush.CenterPoint = new PointF((rect.Left + rect.Right) / 3,
  26.             (rect.Top + rect.Bottom) / 3);
  27.         pgbrush.CenterColor = Color.White;
  28.         pgbrush.SurroundColors = new Color[] { Color.Red };
  29.  
  30.         grfx.FillRectangle(pgbrush, rect);
  31.     }
  32. }
  33.